-- reduce_attrib2
-- create by panyl
-- 属性降低N

return {
    apply = function(prop, baseValue)
		local value = baseValue - prop[3];
		-- 如果原来大于0，则不得少于1点
		if baseValue > 0 then
			value = math.max(1, value);
		end

        return value;
    end,

    desc = function(prop)
        local row = PropM.getRow(prop[1]);
        local desc = row.desc;

        local key = FormulaM.invoke("CALC_SKILL_APPEND_PROP", 51);
        if key and prop[2] == "attack" then
            local p = PropM.combine(ME.user, key, 51);
            local append = PropM.apply(p, prop[3]);
--            local currHp = target.dbase:query("hp", 0);
--            local append = currHp - math.max(1, currHp - reduceHp);
            if append > 0 then
                desc = row.append_desc;
                desc = string.gsub(desc, "{append}", append);
            end
        end

        local attrib = FieldsM.getFieldName(prop[2]);
        if attrib then
            desc = string.gsub(desc, "{0}", attrib);
        end
        desc = string.gsub(desc, "{1}", prop[3]);

        return desc;
    end,

    record = function(target, prop, path)
        return false;
    end
};
